<script lang="ts" setup>
defineOptions({
  name: 'AppGlobalMounted',
})
const { VITE_CASINO_IMG_CLOUD_URL } = getEnv()
const { isLogin } = storeToRefs(useAppStore())

function setAppDeviceNumber() {
  const deviceNumber = getUrlParam('devicenumber')
  if (deviceNumber)
    Local.set(STORAGE_FINGERPRINT, deviceNumber)
}

function handleWindowOnload() {
  // 如果href中有c或者u参数，且未登录，则打开注册弹窗
  if (!isLogin.value) {
    // const c = getUrlParam('c')
    const u = getUrlParam('u')
    if (u) { // c ||
      setTimeout(() => {
        i18nNavigateTo('/login/regist')
      }, 3000)
    }
  }
}

function localSaveC_U() {
  const c = getUrlParam('c')
  const u = getUrlParam('u')
  if (c)
    Local.set(STORAGE_CCCCC, c.replace(/\//g, ''))

  if (u)
    Local.set(STORAGE_UUUUU, u.replace(/\//g, ''))
}

function createGlobalFontLink() {
  const linkTag = document.createElement('link')
  linkTag.setAttribute('rel', 'stylesheet')
  linkTag.setAttribute('href', `${VITE_CASINO_IMG_CLOUD_URL}/aba0ebl.css`)
  document.head.appendChild(linkTag)
}

onMounted(() => {
  handleWindowOnload()
  setAppDeviceNumber()
  localSaveC_U()
  createGlobalFontLink()
})
</script>

<template>
  <div />
</template>
